package com.lzh.others.basejava.Exception_12;

import java.util.Objects;

/**
 * @author by lzh
 * @Classname TestObj
 * @Description TODO
 * @Date 2022/6/27 23:51
 */
public class TestObjException {
    public static void main(String[] args) {
        ObjectBean objectBean = null;
        try {
            System.out.println(objectBean.getId());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class ObjectBean {
    String id;
    String name;

    public ObjectBean() {
    }

    public ObjectBean(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ObjectBean that = (ObjectBean) o;
        return Objects.equals(id, that.id) && Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }

    @Override
    public String toString() {
        return "ObjectBean{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                '}';
    }
}
